package com.softtown.common.regularUtils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author: Dingyayong
 * @Date: 2019/5/28 14:03
 * @Description:
 */
public class RegularUtils {
    /**
     * 判断公司名称中是否有特殊符号
     *
     * @param COMPANY_NAME
     * @return
     * @author Dingyayong
     * @date 2019/6/3 16:22
     */
    public static final String COMPANY_NAME = "[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~！@#￥%……&*——+|{}【】‘；：”“’。，、？]";
    /**
     * 判断手机号
     *
     * @param MOBILE_REGULAR
     * @return
     * @author Dingyayong
     * @date 2019/5/29 9:34
     */
    private static final
    String MOBILE_REGULAR = "^((12[0-9])|(13[0-9])|(14[0-9])|(15([0-9]))|(166)|(17[0-9])|(18[0-9])|(19[0-9]))\\d{8}$";

    /**
     * 判断密码是否为数字和字母组合
     *
     * @param reg
     * @return
     * @author Dingyayong
     * @date 2019/5/29 9:35
     */
    private static final
    String REG = "^(?=.*[0-9])(?=.*[a-zA-Z])(.{6,16})$";
    /**
     * 判断是否为数字
     *
     * @param NUM NUM
     * @return
     * @author Dingyayong
     * @date 2019/5/29 9:43
     */
    private static final String NUM = "^\\d+$";

    /**
     * @Title:
     * @Description: 判断统一社会信用代码
     * @param @param
     * @return @return
     * @author fuming
     * @throws
     * @date 2019/5/31 16:53
     */
    private static final String USCC = "^[A-Z0-9]{18}$";

    /**
     * @Title:
     * @Description: 判断姓名
     * @param @param
     * @return @return
     * @author fuming
     * @throws
     * @date 2019/5/31 17:00
     */
    private static final String NAME = "/^[\\u4E00-\\u9FA5\\uf900-\\ufa2d·s]{2,20}$/";

    /**
     * @Title:
     * @Description: 判断固话
     * @param @param
     * @return @return
     * @author fuming
     * @throws
     * @date 2019/5/31 18:08
     */
    private static final String TEL = "^([0-9]{3,4}-)?[0-9]{7,8}$";

    /**
     * @Title:
     * @Description: 判断部门名称是否有特殊符号
     * @param @param
     * @return @return
     * @author fuming
     * @throws
     * @date 2019/6/6 23:09
     */
    private static final String DEPARTMENT_NAME = "[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~！@#￥%……&*——+|{}【】‘；：”“’。，、？]";

    /**
     * @Title:
     * @Description: 判断岗位名称是否有特殊符号
     * @param @param
     * @return @return
     * @author fuming
     * @throws
     * @date 2019/6/9 13:56
     */
    private static final String POSITION_NAME = "[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~！@#￥%……&*——+|{}【】‘；：”“’。，、？]";

    /**
     * @Title:
     * @Description: 判断真实姓名是否有特殊符号
     * @param @param
     * @return @return
     * @author fuming
     * @throws
     * @date 2019/7/5 21:51
     */
    private static final String REAL_NAME = "[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~！@#￥%……&*——+|{}【】‘；：”“’。，、？]";

    /**
     * @Title:
     * @Description: 判断邮箱是否有正确
     * @param @param
     * @return @return
     * @author fuming
     * @throws
     * @date 2019/7/5 21:57
     */
    private static final String EMAIL = "^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$";

    /**
     * @Title:
     * @Description: 判断费目是否有特殊符号
     * @param @param
     * @return @return
     * @author fuming
     * @throws
     * @date 2019/7/24 20:04
     */
    private static final String EXPENSE_ITEM_NAME = "[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~！@#￥%……&*——+|{}【】‘；：”“’。，、？]";

    /**
     * @Title:
     * @Description: 判断费用归集码或名称是否有特殊符号
     * @param @param
     * @return @return
     * @author fuming
     * @throws
     * @date 2019/7/25 14:53
     */
    private static final String EXPENSE_COLLECTION_CODE_OR_NAME = "[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~！@#￥%……&*——+|{}【】‘；：”“’。，、？]";

    /**
     * @Title:
     * @Description: 判断汇率是否为数字加小数点或者纯数字
     * @param @param
     * @return @return
     * @author fuming
     * @throws
     * @date 2019/7/25 22:14
     */
    private static final String EXCHANGE_RATE = "([1-9]\\d*\\.?\\d*)|(0\\.\\d*[1-9])";

    /**
     * 判断公司名称中是否有特殊符号
     *
     * @param companyName
     * @return
     * @author Dingyayong
     * @date 2019/6/3 16:22
     */
    public static boolean isCompName(String companyName) {
        Pattern p = Pattern.compile(COMPANY_NAME);
        Matcher m = p.matcher(companyName);
        return m.find();
    }

    /**
     * @param @param [uscc]
     * @return @return boolean
     * @throws
     * @Title: isUSCC
     * @Description: 判断USCC是否满足相应正则的方法
     * @author fuming
     * @date 2019/5/31 17:21
     */
    public static boolean isuscc(String uscc) {
        Pattern p = Pattern.compile(USCC);
        Matcher m = p.matcher(uscc);
        return m.matches();
    }

    /**
     * @param @param [name]
     * @return @return boolean
     * @throws
     * @Title: isName
     * @Description: 判断姓名是否满足相应正则的方法
     * @author fuming
     * @date 2019/5/31 17:21
     */
    public static boolean isName(String name) {
        Pattern p = Pattern.compile(NAME);
        Matcher m = p.matcher(name);
        return m.find();
    }

    /**
     * @param @param [tel]
     * @return @return boolean
     * @throws
     * @Title: isTEL
     * @Description: 判断固话是否满足相应正则的方法
     * @author fuming
     * @date 2019/5/31 18:10
     */
    public static boolean istel(String tel) {
        Pattern p = Pattern.compile(TEL);
        Matcher m = p.matcher(tel);
        return m.matches();
    }

    /**
     * @Title: isDeptName
     * @Description: 判断部门名称是否满足相应正则的方法
     * @param @param [departmentName]
     * @return @return boolean
     * @author fuming
     * @throws
     * @date 2019/6/6 23:11
     */
    public static boolean isDeptName(String departmentName) {
        Pattern p = Pattern.compile(DEPARTMENT_NAME);
        Matcher m = p.matcher(departmentName);
        return m.find();
    }

    /**
     * @Title: isPosnName
     * @Description: 判断岗位名称是否满足相应正则的方法
     * @param @param [positionName]
     * @return @return boolean
     * @author fuming
     * @throws
     * @date 2019/6/14 16:31
     */
    public static boolean isPosnName(String positionName) {
        Pattern p = Pattern.compile(POSITION_NAME);
        Matcher m = p.matcher(positionName);
        return m.find();
    }

    /**
     * @Title: isRealName
     * @Description: 判断真实姓名是否满足相应正则的方法
     * @param @param [realName]
     * @return @return boolean
     * @author fuming
     * @throws
     * @date 2019/7/5 21:52
     */
    public static boolean isRealName(String realName) {
        Pattern p = Pattern.compile(REAL_NAME);
        Matcher m = p.matcher(realName);
        return m.find();
    }

    /**
     * @Title: isEmail
     * @Description: 判断邮箱是否满足相应正则的方法
     * @param @param [email]
     * @return @return boolean
     * @author fuming
     * @throws
     * @date 2019/7/5 21:58
     */
    public static boolean isEmail(String email) {
        Pattern p = Pattern.compile(EMAIL);
        Matcher m = p.matcher(email);
        return m.matches();
    }

    public static boolean isMobile(String mobile) {
        Pattern p = Pattern.compile(MOBILE_REGULAR);
        Matcher m = p.matcher(mobile);
        return m.matches();
    }

    public static boolean ispwd(String password) {
        Pattern p = Pattern.compile(REG);
        Matcher m = p.matcher(password);
        return m.matches();
    }

    public static boolean isNum(String num) {
        Pattern p = Pattern.compile(NUM);
        Matcher m = p.matcher(num);
        return m.matches();
    }

    /**
     * @Title: isExpItemName
     * @Description: 判断费目是否满足相应正则的方法
     * @param @param [expenseItemName]
     * @return @return boolean
     * @author fuming
     * @throws
     * @date 2019/7/24 20:07
     */
    public static boolean isExpItemName(String expenseItemName) {
        Pattern p = Pattern.compile(EXPENSE_ITEM_NAME);
        Matcher m = p.matcher(expenseItemName);
        return m.find();
    }

    /**
     * @Title: isExpClctCdOrName
     * @Description: 判断费用归集码或名称是否满足相应正则的方法
     * @param @param [expClctCdOrName]
     * @return @return boolean
     * @author fuming
     * @throws
     * @date 2019/7/25 14:56
     */
    public static boolean isExpClctCdOrName(String expClctCdOrName) {
        Pattern p = Pattern.compile(EXPENSE_COLLECTION_CODE_OR_NAME);
        Matcher m = p.matcher(expClctCdOrName);
        return m.find();
    }

    /**
     * @Title: isExchangeRate
     * @Description: 判断汇率是否满足相应正则的方法
     * @param @param [exchangeRate]
     * @return @return boolean
     * @author fuming
     * @throws
     * @date 2019/7/25 22:45
     */
    public static boolean isexchangerate(String exchangeRate) {
        Pattern p = Pattern.compile(EXCHANGE_RATE);
        Matcher m = p.matcher(exchangeRate);
        return m.matches();
    }
}
